
const app = getApp();
Component({
  properties: {
    type:{
      type: Number,
      value: 0
    },
    active:{
      type:Number,
      value:0
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    oss_url: app.globalData.oss_url,
    active: 0,
    list: [
      {
        "url": "/pages/main/home/index",
        "iconPath": "/images/tab_bar_ico_1.png",
        "selectedIconPath": "/images/tab_bar_ico_1_hover.png",
        "text": "首页"
      },
      {
        "url": "/pages/gift/getGiftBag/index",
        "iconPath": "/images/tab_bar_ico_3.png",
        "selectedIconPath": "/images/tab_bar_ico_3_hover.png",
        "text": "有礼"
      },
      {
        "url": "/pages/mine/mineindex/index",
        "iconPath": "/images/tab_bar_ico_4.png",
        "selectedIconPath": "/images/tab_bar_ico_4_hover.png",
        "text": "我的"
      }
    ]
  },
  methods: {
    onChange(e) {

      let type=e.currentTarget.dataset.type;  //有无礼金包  0无  1有
      let index=e.detail;   //tabbar的index
      this.tabbarChange(type,index)
   },
   tabbarChange(type,index){
      switch(index){
        case 0:
          wx.switchTab({
            url: this.data.list[index].url
          });
        break;
        case 1:
          if(type==1){
            wx.switchTab({
              url: '/pages/gift/myGiftBag/index'
            });
            this.setData({ active: index});
          }else if(type==0){
            wx.switchTab({
              url: '/pages/gift/getGiftBag/index'
            });
          }
        break;
        case 2:
          wx.switchTab({
            url: this.data.list[index].url
          });
        break;
      }
    },
   }
})
